#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int arr[3][3];
    for (int i = 0;i < a;i++)
    {
        for (int j = 0;j < b;j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int k = 0;
    scanf("%d", &k);
    while (k)
    {
        char c = 'x';int m, n = 0;
        scanf(" %c %d %d", &c, &m, &n);
        if (c == 'r')
        {
            int temp = 0;
            for (int i = 0;i < b;i++)
            {
                temp = arr[m - 1][i];
                arr[m - 1][i] = arr[n - 1][i];
                arr[n - 1][i] = temp;
            }
            k--;
        }
        else if (c == 'c')
        {
            int temp = 0;
            for (int i = 0;i < a;i++)
            {
                temp = arr[i][m - 1];
                arr[i][m - 1] = arr[i][n-1];
                arr[i][n - 1] = temp;
            }
            k--;
        }
        else
        {
            k--;
        };
    }
    for (int i = 0;i < a;i++)
    {
        for (int j = 0;j < b;j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}